package com.qing.springcloud.controller;

import com.qing.springcloud.annotation.RequireLogin;
import com.qing.springcloud.annotation.ResponseResult;
import com.qing.springcloud.annotation.SkipLoginCheck;
import com.qing.springcloud.dto.user.UserDTO;
import com.qing.springcloud.dto.user.UserRegisterDTO;
import com.qing.springcloud.dto.user.UserUpdateDTO;
import com.qing.springcloud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author caozhipeng
 * @date 2025/7/15
 */
@RestController
@RequestMapping("/user")
@RequireLogin
public class UserController {
    @Autowired
    private UserService userService;

//    @GetMapping("/ws/auth")
    @GetMapping("/getInfo")
    public UserDTO getUserInfo(){
        return userService.getUserInfo();
    };

    //   注册用户
    @PostMapping("/register")
    @SkipLoginCheck
    public UserDTO register(@RequestBody UserRegisterDTO dto){
        return userService.register(dto);
    };


    //    修改信息
    @PostMapping("/update")
    public void updateUserInfo(@RequestBody UserUpdateDTO dto){
        userService.updateUserInfo(dto);
    };
}
